/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GuiGenerator.java
 *
 * Created on 12/04/2011, 10:25:10 PM
 */
package GUI;


import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.FlowLayout;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author administrador
 */
public class GuiGenerator extends javax.swing.JFrame {

    private String cfuente = "";
    private String cfuenteE = "";
    private int contador = 0;
    private FrameManager fm;

    /** Creates new form GuiGenerator */
    public GuiGenerator() {
        fm = new FrameManager("");
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        rEstadoVentana = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        tTitulo = new javax.swing.JTextField();
        tAlto = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        tAncho = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        cColorFondo = new javax.swing.JComboBox();
        cColorTexto = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        rMax = new javax.swing.JRadioButton();
        rMin = new javax.swing.JRadioButton();
        jLabel9 = new javax.swing.JLabel();
        chCerrar = new javax.swing.JCheckBox();
        chResize = new javax.swing.JCheckBox();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        tValorElemento = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        cElementos = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        tAltoElemento = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        tAnchoElemento = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        Telementos = new javax.swing.JTable();
        jLabel14 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Generador de GUI (Interfaz Gráfica de Usuarios)");
        setResizable(false);

        jLabel1.setText("Título de la ventana:");

        tTitulo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tTituloActionPerformed(evt);
            }
        });

        tAlto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tAltoActionPerformed(evt);
            }
        });
        tAlto.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tAltoFocusLost(evt);
            }
        });

        jLabel2.setText("Tamaño de la ventana:");

        tAncho.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tAnchoActionPerformed(evt);
            }
        });
        tAncho.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tAnchoFocusLost(evt);
            }
        });

        jLabel3.setText("jLabel3");

        jLabel4.setText("Ancho");

        jLabel5.setText("Alto");

        jLabel6.setText("Color de la ventana");

        cColorFondo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "RED", "YELLOW", "GREEN", "BLUE", "WHITE", "BLACK", "GREY", "ORANGE", "PINK", "PURPLE" }));

        cColorTexto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "RED", "YELLOW", "GREEN", "BLUE", "WHITE", "BLACK", "GREY", "ORANGE", "PINK", "PURPLE" }));

        jLabel7.setText("Color de texto de la ventana");

        jLabel8.setText("Estado de la ventana:");

        rEstadoVentana.add(rMax);
        rMax.setMnemonic('1');
        rMax.setSelected(true);
        rMax.setText("Máximizada");
        rMax.setToolTipText("Máximizada");
        rMax.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rMaxActionPerformed(evt);
            }
        });

        rEstadoVentana.add(rMin);
        rMin.setMnemonic('2');
        rMin.setText("Minimizada");
        rMin.setToolTipText("Minimizada");

        jLabel9.setText("Permite:");

        chCerrar.setText("Cerrar");

        chResize.setText("Cambiar tamaño");

        jButton2.setText("Generar ventana");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Limpiar");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("Ver código fuente");
        jButton4.setEnabled(false);
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        tValorElemento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tValorElementoActionPerformed(evt);
            }
        });

        jLabel13.setText("Valor");

        cElementos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Label", "Button", "TextField", "TextArea", "ComboBox", "RadioButton", "CheckBox", "PasswordField" }));

        jLabel10.setText("Agregar elementos:");

        tAltoElemento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tAltoElementoActionPerformed(evt);
            }
        });

        jLabel11.setText("Alto");

        tAnchoElemento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tAnchoElementoActionPerformed(evt);
            }
        });

        jLabel12.setText("Ancho");

        jButton1.setText("Agregar Elemento");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        Telementos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Elemento", "Valor", "Alto", "Ancho"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(Telementos);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 667, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel10)
                        .addGap(18, 18, 18)
                        .addComponent(cElementos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tAltoElemento, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tAnchoElemento, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(39, 39, 39)
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tValorElemento, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addGap(275, 275, 275)
                        .addComponent(jButton1)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel10)
                        .addComponent(cElementos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(tAltoElemento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel11)
                        .addComponent(tAnchoElemento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel12)
                        .addComponent(tValorElemento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel13)))
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
                .addContainerGap())
        );

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel14.setForeground(new java.awt.Color(0, 0, 153));
        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel14.setText("Realizado por John Carlos Espitia Rivera - Universidad Católica de Colombia - Ingeniería de Sistemas - 2011");
        jLabel14.setToolTipText("Realizado por John Carlos Espitia Rivera - Universidad Católica de Colombia - Ingeniería de Sistemas ");
        jLabel14.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel14MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(jLabel6)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(cColorFondo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(18, 18, 18)
                                                .addComponent(jLabel7))
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(jLabel8)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(rMax)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(rMin)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(jLabel9)
                                                .addGap(26, 26, 26)
                                                .addComponent(chCerrar)
                                                .addGap(18, 18, 18)
                                                .addComponent(chResize))
                                            .addComponent(cColorTexto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(jLabel1)
                                                .addGap(18, 18, 18)
                                                .addComponent(tTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(18, 18, 18)
                                                .addComponent(jLabel2)
                                                .addGap(18, 18, 18)
                                                .addComponent(tAlto, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(18, 18, 18))
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                                .addComponent(jLabel5)
                                                .addGap(40, 40, 40)))
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addGap(10, 10, 10)
                                                .addComponent(jLabel4))
                                            .addComponent(tAncho, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGap(45, 45, 45))
                            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButton3)
                        .addGap(18, 18, 18)
                        .addComponent(jButton4)
                        .addGap(18, 18, 18)
                        .addComponent(jButton2)
                        .addGap(123, 123, 123))))
            .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 711, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(tTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel2))
                    .addComponent(tAlto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tAncho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(cColorFondo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)
                            .addComponent(cColorTexto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(rMax)
                    .addComponent(rMin)
                    .addComponent(jLabel9)
                    .addComponent(chResize)
                    .addComponent(chCerrar))
                .addGap(18, 18, 18)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton4)
                    .addComponent(jButton3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addComponent(jLabel14))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tTituloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tTituloActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tTituloActionPerformed

    private void tAltoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tAltoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tAltoActionPerformed

    private void tAnchoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tAnchoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tAnchoActionPerformed

    private void rMaxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rMaxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_rMaxActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        DefaultTableModel modelo = (DefaultTableModel) this.Telementos.getModel();
        this.contador++;
        try {
            int altoE = Integer.parseInt(tAltoElemento.getText());
            int anchoE = Integer.parseInt(tAnchoElemento.getText());
            this.cfuenteE += this.fm.agregarElemento(cElementos.getSelectedIndex(),
                    cElementos.getSelectedItem().toString() + this.contador,
                    altoE, anchoE, this.tValorElemento.getText());
            Object nuevo[] = {cElementos.getSelectedItem().toString(), this.tValorElemento.getText(), altoE, anchoE};
            modelo.addRow(nuevo);
            tAltoElemento.setText("");
            tAnchoElemento.setText("");
            tValorElemento.setText("");
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "El ancho y alto del elemento deben ser valores numericos", "Error de datos", JOptionPane.ERROR_MESSAGE);
        }

    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        int alto = 100;
        int ancho = 100;
        this.cfuente="";
        try {
            alto = Integer.parseInt(tAlto.getText());
            ancho = Integer.parseInt(tAncho.getText());
            this.fm.setTitle(this.tTitulo.getText());
            this.fm.pack();
            this.cfuente += "\n\t\t//Le asignamos el tipo de LayoutManager"
                    + "\n\t\tfr.setLayout( new FlowLayout(FlowLayout.LEADING));\n"
                    + "";
            this.cfuente += fm.permitirMaxMin((rMax.isSelected()) ? 1 : 2);
            this.cfuente += fm.permitirReajuste(chResize.isSelected());
            this.cfuente += fm.permitirCerrar(chCerrar.isSelected());
            this.cfuente += fm.ajustarColor(cColorFondo.getSelectedItem().toString(), cColorTexto.getSelectedItem().toString());
            this.cfuente += fm.ajustarTamanioAlto(alto);
            this.cfuente += fm.ajustarTamanioAncho(ancho);
            this.cfuente += this.cfuenteE;
            fm.setLayout( new FlowLayout(FlowLayout.LEADING));
            fm.setVisible(true);
            this.cfuente += "\n\t\t//Empaquetamos los elementos en la ventana\n\t\tfr.pack();\n";
            this.cfuente += "\n\t\t//Hacemos visible la ventana\n\t\tfr.setVisible(true);\n";
            jButton4.setEnabled(true);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "El ancho y alto deben ser valores numericos", "Error de datos", JOptionPane.ERROR_MESSAGE);
            alto = 100;
            ancho = 100;

        }

    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

        tAlto.setText("");
        tAncho.setText("");
        tTitulo.setText("");
        cColorFondo.setSelectedIndex(0);
        cColorTexto.setSelectedIndex(0);
        chCerrar.setSelected(false);
        chResize.setSelected(false);
        rMax.setSelected(true);
        jButton4.setEnabled(false);
        tAltoElemento.setText("");
        tAnchoElemento.setText("");
        tValorElemento.setText("");
        DefaultTableModel modelo = (DefaultTableModel) this.Telementos.getModel(); // para manipular el objeto en un modelo
        modelo.setRowCount(0);
        fm.setVisible(false);
        fm = new FrameManager("");
        this.cfuente = "";

    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        String content = "import java.awt.*;\nimport java.awt.event.*;";
        content += "\n/**\n*\n* @author John Carlos Espitia\n*/\npublic class FrameManager {";
        content += "\n\tpublic static void main(String args[]) {\n\t\t//Creamos el objeto ventana (java.awt.frame)\n\t\tFrame fr;\n\t\t//Instanciamos el objeto\n\t\tfr=new Frame(\"" + this.tTitulo.getText() + "\");\n\t\t//Asignamos el título de la ventana\n\t\tfr.setTitle(\"" + this.tTitulo.getText() + "\");\n\t\t" + cfuente + "\n\t}\n}";
        new VerFuente(this, true, content).setVisible(true);
    }//GEN-LAST:event_jButton4ActionPerformed

    private void tAltoElementoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tAltoElementoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tAltoElementoActionPerformed

    private void tAnchoElementoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tAnchoElementoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tAnchoElementoActionPerformed

    private void tValorElementoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tValorElementoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tValorElementoActionPerformed

    private void tAltoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tAltoFocusLost
        try {
            int alto = Integer.parseInt(tAlto.getText());
            this.fm.ajustarTamanioAlto(alto);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "El alto debe ser un valor numerico", "Error de datos", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_tAltoFocusLost

    private void tAnchoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tAnchoFocusLost
        try {
            int ancho = Integer.parseInt(tAncho.getText());
            this.fm.ajustarTamanioAncho(ancho);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "El ancho debe ser un valor numerico", "Error de datos", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_tAnchoFocusLost

    private void jLabel14MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel14MouseClicked
        JOptionPane.showMessageDialog(null, "Realizado por John Espitia\nUniversidad Católica de Colombia\n2011", "Acerca de..", JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jLabel14MouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new GuiGenerator().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable Telementos;
    private javax.swing.JComboBox cColorFondo;
    private javax.swing.JComboBox cColorTexto;
    private javax.swing.JComboBox cElementos;
    private javax.swing.JCheckBox chCerrar;
    private javax.swing.JCheckBox chResize;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.ButtonGroup rEstadoVentana;
    private javax.swing.JRadioButton rMax;
    private javax.swing.JRadioButton rMin;
    private javax.swing.JTextField tAlto;
    private javax.swing.JTextField tAltoElemento;
    private javax.swing.JTextField tAncho;
    private javax.swing.JTextField tAnchoElemento;
    private javax.swing.JTextField tTitulo;
    private javax.swing.JTextField tValorElemento;
    // End of variables declaration//GEN-END:variables
}
